package zhishuang.wang.sansi.playlist;

import zhishuang.wang.sansi.playlist.entry.*;
import zhishuang.wang.sansi.tools.ReturnData;

/**
 * @Author Zhishuang.Wang
 * @Date 2023/7/5 11:12
 * @Email 1406110602@qq.com
 */

public class PlayItem {
    private Integer x;
    private Integer y;
    private Integer playNo;
    private Integer materialType;
    private String id;
    private String name;
    private PlayTimeBase playTime;
    private Animation animation;
    private TextBase textBase;
    private PictureBase pictureBase;
    private VideoBase videoBase;

    public PlayItem() {
    }

    public PlayItem(int playNo, String id, String name, TextBase textBase, PlayTimeBase playTime) {
        this.playNo = playNo;
        this.id = id;
        this.name = name;
        this.textBase = textBase;
        this.playTime = playTime;
        this.materialType = 1;
    }

    public PlayItem(int playNo, String id, String name, PictureBase pictureBase, PlayTimeBase playTime) {
        this.playNo = playNo;
        this.id = id;
        this.name = name;
        this.pictureBase = pictureBase;
        this.playTime = playTime;
        this.materialType = 2;
    }

    public PlayItem(int playNo, String id, String name, VideoBase videoBase, PlayTimeBase playTime) {
        this.playNo = playNo;
        this.id = id;
        this.name = name;
        this.videoBase = videoBase;
        this.playTime = playTime;
        this.materialType = 3;
    }

    public ReturnData checkParam() {
        ReturnData rd = new ReturnData();
        rd.setCode(1);
        String errorMes = "";
        if (this.playNo != null && this.materialType != null && this.id != null && this.name != null && this.id.length() != 0 && this.name.length() != 0 && this.playTime != null) {
            if (this.playNo > 0) {
                ReturnData checkRd = null;
                if (this.materialType == 1) {
                    if (this.textBase == null) {
                        errorMes = errorMes + "文本素材信息必填；";
                    } else {
                        checkRd = this.textBase.checkParam();
                        if (checkRd.getCode() != 0) {
                            errorMes = errorMes + "播放项文本信息错误：" + checkRd.getMessage();
                        }
                    }
                } else if (this.materialType == 2) {
                    if (this.pictureBase == null) {
                        errorMes = errorMes + "图片素材信息必填；";
                    } else {
                        checkRd = this.pictureBase.checkParam();
                        if (checkRd.getCode() != 0) {
                            errorMes = errorMes + "播放项图片信息错误：" + checkRd.getMessage();
                        }
                    }
                } else if (this.materialType == 3) {
                    if (this.videoBase == null) {
                        errorMes = errorMes + "视频素材信息必填；";
                    } else {
                        checkRd = this.videoBase.checkParam();
                        if (checkRd.getCode() != 0) {
                            errorMes = errorMes + "播放项视频信息错误：" + checkRd.getMessage();
                        }
                    }
                } else {
                    errorMes = errorMes + "素材类型不支持，取值范围：1 - 3；";
                }

                if (this.animation != null) {
                    checkRd = this.animation.checkParam();
                    if (checkRd.getCode() != 0) {
                        errorMes = errorMes + "播放项动画效果错误：" + checkRd.getMessage();
                    }
                }

                checkRd = this.playTime.checkParam();
                if (checkRd.getCode() != 0) {
                    errorMes = errorMes + "播放项播放时间错误：" + checkRd.getMessage();
                }
            } else {
                errorMes = errorMes + "播放序号必填从1开始；";
            }
        } else {
            errorMes = errorMes + "播放项唯一ID、播放项名称、播放序号、素材类型、播放时间等必填；";
        }

        if (errorMes != null && errorMes.length() != 0) {
            rd.setMessage(errorMes);
        } else {
            rd.setCode(0);
        }

        return rd;
    }

    public Integer getMaterialType() {
        return this.materialType;
    }

    public void setMaterialType(Integer materialType) {
        this.materialType = materialType;
    }

    public Integer getPlayNo() {
        return this.playNo;
    }

    public void setPlayNo(Integer playNo) {
        this.playNo = playNo;
    }

    public TextBase getTextBase() {
        return this.textBase;
    }

    public void setTextBase(TextBase textBase) {
        this.textBase = textBase;
    }

    public PictureBase getPictureBase() {
        return this.pictureBase;
    }

    public void setPictureBase(PictureBase pictureBase) {
        this.pictureBase = pictureBase;
    }

    public VideoBase getVideoBase() {
        return this.videoBase;
    }

    public void setVideoBase(VideoBase videoBase) {
        this.videoBase = videoBase;
    }

    public String getId() {
        return this.id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return this.name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Animation getAnimation() {
        return this.animation;
    }

    public void setAnimation(Animation animation) {
        this.animation = animation;
    }

    public PlayTimeBase getPlayTime() {
        return this.playTime;
    }

    public void setPlayTime(PlayTimeBase playTime) {
        this.playTime = playTime;
    }

    public Integer getY() {
        return this.y;
    }

    public void setY(Integer y) {
        this.y = y;
    }

    public Integer getX() {
        return this.x;
    }

    public void setX(Integer x) {
        this.x = x;
    }
}
